//
//  YWHeadView.m
//  网易新闻
//
//  Created by Yeewii@hotmail.com on 16/6/15.
//  Copyright © 2016年 Yeewii@hotmail.com. All rights reserved.
//

#import "YWHeadView.h"

#define HEADEHEIGH 200


@implementation YWHeadView
{
    SDCycleScrollView *_scrollView;
}

-(instancetype)init
{
    if (self = [super init])
    {
        [self createScrollView];
    }
    return self;
}

-(void)createScrollView
{
    _scrollView                     = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, MAINWIDTH, HEADEHEIGH) delegate:self placeholderImage:[UIImage imageNamed:@"daiZai"]];
    _scrollView.pageControlAliment  = SDCycleScrollViewPageContolAlimentCenter;
    _scrollView.currentPageDotColor = [UIColor yellowColor];
    _scrollView.delegate            = self;
    _scrollView.pageControlAliment  = SDCycleScrollViewPageContolAlimentRight;
    [self addSubview:_scrollView];
}


#pragma mark - setMethed -
-(void)setModelAds:(NSArray *)ModelAds
{
    _ModelAds                        = ModelAds;
    NSMutableDictionary *picDic      = [NSMutableDictionary dictionary];
    for (YWDataAds *ads in _ModelAds)
    {
        [picDic setObject:ads.imgsrc forKey:ads.title];
    }
    _scrollView.titlesGroup          = picDic.allKeys;
    _scrollView.imageURLStringsGroup = picDic.allValues;
}


#pragma mark - delegate -
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index;
{
    NSLog(@"U touch Number %d",(int)index);
}

+(CGFloat)headHeight
{
    return HEADEHEIGH;
}
@end
